<?php 
use Wdl\helper\VillageHelper;
use Wdl\helper\webHelper;
 
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
load()->func('tpl'); 
$uniacid = webHelper::bindUniacid(); 
$openid = $_W['openid'];
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'home';	

if($operation == 'house'){
    //总房源
    $total = pdo_fetchcolumn("select count(*) as total from "
        .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype",
        ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype']]
    );
    //今日发布
    $today = pdo_fetchcolumn("select count(*) as total from "
    .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype and add_time>:add_time",
    ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype'], 'add_time'=> TIMESTAMP- 24*3600 ]
    );
    //在售房源
    $online = pdo_fetchcolumn("select count(*) as total from "
    .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype  and isonline=1 and isdelete=0 ",
    ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype']  ]
    );
    //下架房源
    $down = pdo_fetchcolumn("select count(*) as total from "
    .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype  and isonline=0 and isdelete=0 ",
    ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype']  ]
    );
    //7日内更新
    $in7day = pdo_fetchcolumn("select count(*) as total from "
    .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype and refresh_time>:refresh_time",
    ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype'], 'refresh_time'=> TIMESTAMP- 24*3600*7 ]
    );
    //超过7天有效期
    $outday = pdo_fetchcolumn("select count(*) as total from "
    .tablename('kbwdl_house') ." where uniacid=:uniacid and zhutype=:zhutype and endtime < :endtime",
    ['uniacid'=> $uniacid, 'zhutype'=> $_GPC['zhutype'], 'endtime'=> TIMESTAMP- 24*3600*7 ]
    );
    include $this->template('stdata/house');
}

